import 'dart:html';

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AppBar 组件',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: Text('AppBar 组件'),),
        body: DemoPage(),
      ),
    );
  }
}

class DemoPage extends StatefulWidget {
  @override
  DemoPagesState create State() => DemoPagesState();
}

class DemoPagesState extends State<DemoPage> {
  @override
  Widget build(BuildContext context) {
    // return SizedBox(
    //   height: 200.0,
    //   child: AppBar(
    //     title: Text('应用'),
    //     actions:<Widget>[
    //       IconButton(
    //         onPressed: (){},
    //         icon: Icon(Icons.print),
    //         tooltip: '打印',
    //       ),
    //       IconButton(
    //         onPressed: (){},
    //         icon: Icon(Icons.plus_one),
    //         tooltip: '更多',
    //       ),
    //       IconButton(
    //         onPressed: (){},
    //         icon: Icon(Icons.share),
    //         tooltip: '分享',
    //       ),
    //     ]
    //   ),
    // )

    return SizedBox(
      height: 500,
      child: AppBar(
        title: Text(''),
        leading: Icon(Icons.home),
        backgroundColor: Colors.green,
        //居中显示
        centerTitle: true,
        actions: <Widget>[
          IconButton(
              onPressed: (){},
              icon: Icon(Icons.print),
            tooltip: '打印',
          ),
          //菜单按钮
          PopupMenuButton<String>(
            itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
              //菜单项
              PopupMenuItem<String>(
              value:'friend',
                child: Text('分享倒朋友圈'),
              ),
              PopupMenuItem<String>(
                value: 'download',
                child: Text('下载倒本地'),
              )
            ],
          )
        ],
      ),
    )
  }
}